﻿/*-------------------------------------------------------------------------
* 版权所有：JoneZhu
* 作者：朱宏达
* 联系方式：zhuhongda@gyyx.cn
* 创建时间：2014-07-15 19:32:47
* 版本号：v1.0
* 本类主要用途描述：
* 此类主要用作Mapper.xml的生成
-------------------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MapperHelper
{
    /// <summary>
    /// 获取更新语句的Set语句
    /// </summary>
    /// <returns></returns>
    public static string GetUpdateSetStr(TableObj tableObj)
    {
        //game_name=#{gameName}
        string reuslt = "";
        foreach (var col in tableObj.UnPkcolumnList)
        {
            reuslt += col.OrginName + "=#{" + col.FieldName + "},";
        }

        return reuslt.Trim(',');
    }

    /// <summary>
    /// 获取更新语句的Where语句
    /// </summary>
    /// <returns></returns>
    public static string GetPkWhereStr(TableObj tableObj)
    {
        //game_name=#{gameName}
        string reuslt = "";
        foreach (var col in tableObj.PkColumnList)
        {
            reuslt += col.OrginName + "=#{" + col.FieldName + "},";
        }

        return reuslt.Trim(',');
    }

    /// <summary>
    /// 获取插入语句的insert into语句
    /// </summary>
    /// <returns></returns>
    public static string GetInsertIntoStr(TableObj tableObj)
    {
        string reuslt = "";
        foreach (var col in tableObj.UnIncreColumnList)
        {
            reuslt += col.OrginName + ",";
        }

        return reuslt.Trim(',');
    }

    /// <summary>
    /// 获取插入语句的insert Value语句
    /// </summary>
    /// <returns></returns>
    public static string GetInsertValueStr(TableObj tableObj)
    {
        string reuslt = "";
        foreach (var col in tableObj.UnIncreColumnList)
        {
            reuslt += "#{" + col.FieldName + "},";
        }

        return reuslt.Trim(',');
    }

    /// <summary>
    /// 获取方法参数签名
    /// </summary>
    /// <returns></returns>
    public static string GetMethodParaStr(TableObj tableObj)
    {
        string reuslt = "";
        foreach (var col in tableObj.PkColumnList)
        {
            reuslt += col.DataType + " " + col.FieldName + ",";
        }

        return reuslt.Trim(',');
    }

}
